import { classicBehavior } from '../classic-beh.js'

let mMgr = wx.getBackgroundAudioManager()

Component({
  /**
   * 组件的属性列表
   */
  behaviors: [classicBehavior],

  properties: {
    src: String,
    title:String
  },

  /**
   * 组件的初始数据
   */
  data: {
    playing: false,
    waittingUrl: 'images/player@waitting.png',
    playingUrl: 'images/player@playing.png'
  },

  attached: function() {
  },

  detached: function() {
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onPlay() {
      if (!this.data.playing){
          this.setData({
            playing:true
          })
        mMgr.src = this.properties.src
        mMgr.title  = this.properties.src
      }else{
        this.setData({
          playing: false
        })
        mMgr.pause()
      }
    }
  }
})